package com.ly.work;

public class Demo02 extends Thread{

    @Override
    public void run() {
        synchronized (Main.class){
            while (Main.i<=100){
                if (Main.i%2==0){
                    System.out.println(Thread.currentThread().getName()+"偶数"+Main.i);
                    Main.i++;
                    Main.class.notify();
                }else {
                    try {
                        Main.class.wait();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}






